package com.imti.mall.product.mapper;


import com.imti.mall.model.pms.pojo.PmsSkuStock;
import org.apache.ibatis.jdbc.SQL;

public class PmsSkuStockDynaSqlProvider {

    /**
     * 根据id修SKU信息详情
     * @param
     * @return
     */
    public String updateSkuStockById(final PmsSkuStock pmsSkuStock){

        return new SQL(){
            {
                UPDATE(" pms_sku_stock ");
                if(pmsSkuStock!=null) {

                    if (pmsSkuStock.getSkuCode() != null) {
                        SET("   sku_code=#{skuCode}");
                    }

                    if (pmsSkuStock.getPrice() != null) {
                        SET("   price=#{price}");
                    }

                    if (pmsSkuStock.getPrice() != null) {
                        SET("  price=#{price}");
                    }
                    if (pmsSkuStock.getStock() != null) {
                        SET("  stock=#{stock}");
                    }
                    if (pmsSkuStock.getLowStock() != null) {
                        SET("   low_stock=#{lowStock}");
                    }
                    if (pmsSkuStock.getPic() != null) {
                        SET("   pic=#{pic}");
                    }
                    if (pmsSkuStock.getSale() != null) {
                        SET("   sale=#{sale}");
                    }
                    if (pmsSkuStock.getPromotionPrice() != null) {
                        SET("   promotion_price=#{promotionPrice}");
                    }
                    if (pmsSkuStock.getLockStock() != null) {
                        SET("   lock_stock=#{lockStock}");
                    }
                    if (pmsSkuStock.getSpData() != null) {
                        SET("   sp_data=#{spData}");
                    }
                }
                WHERE(" id=#{id} ");

            }
        }.toString();

    }
}
